fix: support py_cc_toolchain#1131
Conversation
✨ Aspect Workflows Tasks📅 Fri Jun 19 20:28:35 UTC 2026 ❌ 2 failed tasks
✅ 5 successful tasks
🔁 Reproduce❌ test (test-root-bazel-8 · test-root-bazel-9)Install ⏱ Last updated Fri Jun 19 20:32:29 UTC 2026 · 📊 GitHub API quota 23/15,000 (0% used, resets in 56m) |
py_binary startup benchmark
sys.path quality
|
|
My clanker exercised this path through a rules_py 2 integration and The replacement commit is That commit is currently stacked on several open prerequisite changes, so |
|
I'm not attached to this branch at all if you have an alternate. Your link is a 404 though... |
|
The reviewed replacement is now |
|
Downstream data point: this fixes a real We hit #1095 in a monorepo that sources Python toolchains entirely from Tested this branch (
Because this drives the real Separately (not a claim about this PR): with #1095 previously blocking analysis, we'd never reached runtime to observe #1048 on this path — and at this commit we see no sign of the This (or @tamird's alternative) reaching a mergeable state is the last blocker for our rules_py v2 adoption on native-extension packages, so glad to help validate — happy to re-run against |
|
Correction + a sharper result after digging into toolchain resolution. My earlier "shouldn't be satisfiable by rules_python's fallback C toolchain" was too strong — the masking is real, but version-dependent, and I can now show exactly where it does and doesn't bite. Setup:
So the NOTE in the e2e case is right that a real native build can be masked when Happy to turn this into the repro PR mentioned above: a real |
|
One clarification for anyone finding this thread later: my testing above was against this branch ( Leaving my findings above for reference, but for anyone hitting the py_cc gap: point at |
|
Follow-up to the above: opened #1299 with the nanobind e2e case — a real |
|
@jbedard which bug do you mean? #1299's Bazel 8/9 e2e checks ran both nanobind targets successfully. Its deps edge is intentional: version-sensitive extensions must retain the terminal Python configuration, while data resets to the inherited configuration. The explicit imports = ["."] is also intentional under rules_py's -I launcher so the package-local .so has a declared import root. Current pbs-cc-toolchain and cc-deps coverage already verify that the selected runtime and C payload match, including PY_VERSION_HEX == sys.hexversion. Is there another failing configuration or invariant you mean? |
…1299) Adds an e2e case that builds a real `nanobind_extension` in a graph whose only Python toolchains come from `python_interpreters` (the rules_python `python.toolchain()` drop-in), exercising the `@rules_python//python/cc:current_py_cc_headers` path that nanobind and pybind11 use to resolve Python headers. `pbs-cc-toolchain` already covers the bare `cc_binary` + `current_py_cc_headers`/`current_py_cc_libs` path; this adds the **nanobind** consumer, which is how most real-world native extensions reach `current_py_cc_headers`. It guards the py_cc toolchain registration (issue #1095) against regression. Two targets: - `example_ext_build_test` — a `build_test` over the `nanobind_extension`; fails at analysis if `python_interpreters` does not register `@rules_python//python/cc:toolchain_type`. - `example_ext_test` — compiles, links, loads and calls the extension under a PBS runtime (py 3.13). **End-user visible:** no (test-only). **Breaking:** no. **Test plan:** `bazel test //nanobind-py-cc/...` in `e2e/cases` passes locally (build_test + runtime import/call; Linux x86_64, llvm toolchain). Context: came out of testing the py_cc gap for a real nanobind consumer (discussed in #1131); @jbedard suggested opening this. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Changes are visible to end-users: yes/no
Test plan